<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="pers.cj.pdos.entity.BusinessSet" %>
<%@ page import="pers.cj.pdos.service.IBusinessSetService" %>
<%@ page import="org.apache.shiro.SecurityUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:directive.page import="org.springframework.web.context.WebApplicationContext"/>
<%@ page import="pers.cj.pdos.entity.User" %>
<%@ page import="pers.cj.pdos.vo.UserVo" %>
<%@ page import="pers.cj.pdos.service.IUserService" %>
<%
    //jsp页面中调用spring容器的bean
    WebApplicationContext context = (WebApplicationContext)request.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    IBusinessSetService businessSetService = (IBusinessSetService)context.getBean("businessSetServiceImpl");
    IUserService userService = (IUserService)context.getBean("userServiceImpl");

    UserVo temp = (UserVo) SecurityUtils.getSubject().getPrincipal();
    if (temp != null) {
        UserVo loginUser = userService.getVoById(temp.getId());
        loginUser.setAdmin(temp.isAdmin());
        request.setAttribute("loginUser", loginUser);
        BusinessSet businessSet = businessSetService.getByCompany(loginUser.getCompanyId());
        request.setAttribute("businessSet", businessSet);
    }
%>

<script type="text/javascript">
    let _baseUrl = "${baseUrl}";
    let _login_user = {
        id:"${loginUser.id}",
        admin:isTrue("${loginUser.admin}"),
        retailStatus:getNumber("${loginUser.retailStatus}"),
        username:"${loginUser.username}",
        name:"${loginUser.name}",
        sex:getNumber("${loginUser.sex}"),
        phone:"${loginUser.phone}",
        status:getNumber("${loginUser.status}"),
        price:"${loginUser.price}",
        viewOtherOrder:isTrue("${loginUser.viewOtherOrder}"),
        cancelOtherOrder:isTrue("${loginUser.cancelOtherOrder}"),
        viewOtherCustom:isTrue("${loginUser.viewOtherCustom}"),
        viewOtherHouse:isTrue("${loginUser.viewOtherHouse}"),
        storeId:"${loginUser.storeId}",
        companyId:"${loginUser.companyId}",
        store:{
            id:"${loginUser.store.id}",
            name:"${loginUser.store.name}",
            sys:isTrue("${loginUser.store.sys}"),
        }
    };

    let _businessSet = {
        id:"${businessSet.id}",
        discount: isTrue(${businessSet.discount}),//销售单行折扣开关
        negative: isTrue(${businessSet.negative}),//是否允许负库存销售/调拨
        serial: isTrue(${businessSet.serial}),//是否启用商品序列号
        saleMakeUp: isTrue(${businessSet.saleMakeUp}),//销售时是否自动补齐实收金额
        inMakeUp: isTrue(${businessSet.inMakeUp}),//进货时是否自动补齐实收金额
        writeOff: isTrue(${businessSet.writeOff}),//是否启用核销
        moreHouse: isTrue(${businessSet.moreHouse}),//是否启用多仓库
        oddFlag: ${businessSet.oddFlag},//抹零： 1-抹掉零头到分 2-抹掉零头到角 3-抹掉零头到原 4-不抹零
        pricePoint: ${businessSet.pricePoint},//价格小数位数设置
        numPoint: ${businessSet.numPoint},//数量小数位数设置
        quickPrint: isTrue(${businessSet.quickPrint}),//是否启用快速打印
        inTaxRateFlag: isTrue(${businessSet.inTaxRateFlag}),//启用进货税率支持
        inTaxRate: "${businessSet.inTaxRate}",//进货税率
        saleTaxRateFlag: isTrue(${businessSet.saleTaxRateFlag}),//启用销售税率支持
        saleTaxRate:"${businessSet.saleTaxRate}",//销售税率
        houseInOut:"${businessSet.houseInOut}",//出库入管理
    };
</script>
